package com.actions.bluetoothbox2.util;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.actions.bluetoothbox2.R;

/**
 * Created by liuyong on 2016/7/13.
 */
public class HintDialog extends Dialog {

    Context context;
    String conten;
    View.OnClickListener click;
    TextView dialog_content, dialog_no, dialog_ok;

    public HintDialog(Context context, String content, View.OnClickListener click) {
        super(context);
        this.context = context;
        this.conten = content;
        this.click = click;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_hint);
        dialog_content = (TextView) findViewById(R.id.dialog_content);
        dialog_no = (TextView) findViewById(R.id.dialog_no);
        dialog_ok = (TextView) findViewById(R.id.dialog_ok);
        dialog_content.setText(conten);

        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();

        DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
        lp.width = (int) (d.widthPixels * 0.8); // 宽度设置为屏幕的0.8
        dialogWindow.setAttributes(lp);

        dialog_ok.setOnClickListener(click);
        dialog_no.setOnClickListener(click);
    }
}
